package com.itcast.demo.single;

/**
 * Created by qiyei2015 on 2017/5/13.
 */
public class Instance2 {
    static{
        System.out.println("true = " + true);
    }

    /**
     * 构造方法私有化
     */
    private Instance2(){
        System.out.println("Instance2.......");
    }
    
    private static class SingleHolder{
        private static final Instance2 ins = new Instance2();
    }

    /**
     * 内部类方式获取单例
     * @return
     */
    public static Instance2 getInstance(){
        System.out.println("getInstance.......");
        return SingleHolder.ins;
    }

    public static void main(String[] args) {
        System.out.println("args = " + args);
//        Instance2.getInstance();
    }
    
}
